<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>计数器</title>
</head>
<body>
    <div id="app">
        <h2>当前计数：{{sum}}</h2>
        <button @click="up">+1</button>
        <button @click="down">-1</button>
    </div>
    <script src="../../study/lib/vue.js"></script>
    <script>
        //使用vue
        const app = Vue.createApp({
            //替换其中的内容
            // template:`

            // `,
            //数据函数
            data: function () {
                return {
                    sum: 0
                }
            },
            //对象
            methods: {
                //函数 一些事件绑定
                up: function () {
                    //this是事件绑定
                    this.sum++
                },
                down: function () {
                    this.sum++
                }
            }
        })
        //挂载
        app.mount("#app")
    </script>
</body>
</html>